import java.util.Locale;

public class Test {

    public static boolean func2(String s) {
        s = s.toLowerCase();
        int left = 0;
        int right = s.length()-1;
        while (left < right) {
            while (left<right && !isValidChar(s.charAt(left))) {
                left++;
            }
            while (left<right && !isValidChar(s.charAt(right))) {
                right--;
            }
            if (s.charAt(left) != s.charAt(right)) {
                return false;
            }else {
                left++;
                right--;
            }
        }
        return true;
    }

    public static boolean isValidChar(char ch) {
        if ((ch>='0' && ch<='9') || (ch>='a' && ch<='z')){
            return true;
        }
            return false;
    }

    public static void main(String[] args) {
        System.out.println(func2("a,B, hCcBa"));
    }

    public static int func(String s) {
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            count[ch-'a']++;
        }

        for (int j = 0; j < s.length(); j++) {
            char ch = s.charAt(j);
            if (count[ch-'a'] == 1) {
                return j;
            }
        }
        return -1;
    }

    public static void main5(String[] args) {
        System.out.println(func("aasosk"));
    }

    public static void main4(String[] args) {

        StringBuilder stringBuilder = new StringBuilder("NBA");
        System.out.println(stringBuilder);
        stringBuilder.reverse();
        System.out.println(stringBuilder);

        /*
        StringBuffer stringBuffer = new StringBuffer("abc");
        System.out.println(stringBuffer);
        stringBuffer.reverse();
        System.out.println(stringBuffer);*/
    }

    public static void main3(String[] args) {
        String str1 = "hello!";
        String str2 = "HEllo!";
        System.out.println(str1.toUpperCase());
        System.out.println(str2.toLowerCase());
    }

    public static void main2(String[] args) {
        String str1 = String.valueOf(3203);
        System.out.println(str1);
        System.out.println("---------");
        String str2 = "35";
        int a = Integer.parseInt(str2);
        System.out.println(a);

    }

    public static void main1(String[] args) {
        String str1 = "hello!";
        for (int i = 0; i < str1.length(); i++) {
            System.out.print(str1.charAt(i)+" ");
        }
        System.out.println("---------");
        String str2 = "helloxkdnkanask!";;
        System.out.println(str2.indexOf("k"));
        System.out.println(str2.indexOf("oxkd"));
        System.out.println("---------");
        String str3 = "hddjzjxlnask!";;
        System.out.println(str3.lastIndexOf('s'));
    }
}
